package cn.com.dhcc.turbo.service.exch.exhmgr;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.com.dhcc.app.core.exception.DaoException;
import cn.com.dhcc.app.core.exception.ServiceException;
import cn.com.dhcc.app.core.handler.modulehandler.WhereCondition;
import cn.com.dhcc.app.core.handler.pagerhandler.Pager;
import cn.com.dhcc.app.core.handler.pagerhandler.PagerData;
import cn.com.dhcc.app.core.service.BaseService;
import cn.com.dhcc.turbo.dao.registry.ExchConnRequestDao;
import cn.com.dhcc.turbo.entity.registry.ExchConnRequest;

@Service
public class ExchConnRequestService extends BaseService{
	@Autowired
	private ExchConnRequestDao exchConnRequestDao;
	

    public PagerData<ExchConnRequest> list(Pager pager, WhereCondition condition)
			throws ServiceException {
		try {
			return exchConnRequestDao.list(pager, condition);
		} catch (DaoException e) {
			throw new ServiceException(" 获取请求审核信息列表失败", e);
		}
	}

	public void add(ExchConnRequest vo) throws ServiceException {
		try {
			exchConnRequestDao.add(vo);
		} catch (DaoException e) {
			throw new ServiceException(" 获取请求审核信息列表失败", e);
		}

	}

	public ExchConnRequest get(String id) throws ServiceException {
		try {
			return exchConnRequestDao.get(id);
		} catch (DaoException e) {
			throw new ServiceException(" 获取请求审核信息列表失败", e);
		}
	}
	public void auditConnRequest(ExchConnRequest vo) throws ServiceException {
		try {
			 exchConnRequestDao.auditConnRequest(vo);
		} catch (DaoException e) {
			throw new ServiceException(" 审核请求失败", e);
		}
	}
	/**
	 * 统计待审核总数
	 * @return
	 * @throws ServiceException
	 */
	public int getCountRequest()throws ServiceException {
		try {
			 return exchConnRequestDao.getCountRequest();
		} catch (DaoException e) {
			throw new ServiceException("统计待审核总数失败", e);
		}
		
	}
/**
 * 审核结果
 * @param vo
 * @return
 * @throws ServiceException
 */
	public int update(ExchConnRequest vo) throws ServiceException {
		try {
			 return exchConnRequestDao.update(vo);
		} catch (DaoException e) {
			throw new ServiceException("审核结果失败", e);
		}
		
	}
	
	/**
	 * 定时删除已审核记录
	 * @throws ServiceException
	 */
	public void timingDelete(String day) throws ServiceException {
		try {
			exchConnRequestDao.timingDelete(day);
		} catch (DaoException e) {
			throw new ServiceException("定时删除已审核记录失败", e);
		}
	}
}
